package com.sinafenqi.designDemo.proxy.jdkDynamic;

import javassist.CannotCompileException;
import javassist.ClassPool;
import javassist.CtClass;
import javassist.CtMethod;
import sun.misc.ProxyGenerator;

import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @author hujinsheng
 * @project DesignModeproxy
 * @create 2017-11-06 16:28
 **/
public class DynamicProxyTest1 {

    public static void main(String[] args) throws IOException, CannotCompileException {
        ClassPool pool = ClassPool.getDefault();
        CtClass ctClass = pool.makeClass("com.sinafenqi.designDemo.proxy.LiuDehua");
        CtMethod method = CtMethod.make("public void sing(String name){}", ctClass);

        method.insertBefore(" System.out.println(\"我是刘德华的经纪人！！\");");
        ctClass.addMethod(method);
        ctClass.writeFile("D:\\temp");
    }


}
